package com.imy.common.util;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

public class SoftInputUtils {


    /**
     * 显示键盘
     *
     * @param et 输入焦点
     */
    public  static  void showInput(final EditText et, Context context) {
        et.requestFocus();
        InputMethodManager imm = (InputMethodManager)context. getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
    }
    /**
     * 隐藏键盘
     */
    public static void hideInput(View editText, Context context) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm==null){
            return;
        }
        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);

    }
}
